package com.lzy.huijinjiazu.mvp.ui.adapter;

import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.flyco.roundview.RoundTextView;
import com.jess.arms.utils.ArmsUtils;
import com.lzy.huijinjiazu.R;
import com.lzy.huijinjiazu.mvp.ui.widget.TagGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by long on 2018/1/9.
 */

public class HomeCardAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    public HomeCardAdapter() {
        super(R.layout.item_home_card);
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        switchBg(helper);
        TagGroup tgList = helper.getView(R.id.tg_list);
        productionView(tgList, null);
    }

    private void productionView(TagGroup tgList, List<String> data) {
        if (tgList.getChildCount() > 0) {
            return;
        }
        data = new ArrayList<>();
        data.add("腾邦");
        data.add("腾邦");
        tgList.setList(data);
        for (int i = 0; i < tgList.getChildCount(); i++) {
            RoundTextView tvView = (RoundTextView) tgList.getChildAt(i);
            tvView.setText(data.get(i));
            tvView.getDelegate().setStrokeColor(0x99ffffff);
            tvView.setTextColor(0xBFffffff);
            tvView.getDelegate().setBackgroundColor(0x00000000);
            tvView.setTextSize(9);
            tvView.setPadding(15, 5, 15, 5);
        }
    }

    private void switchBg(BaseViewHolder helper) {
        LinearLayout frameLayout = (LinearLayout) helper.itemView;
        switch (helper.getLayoutPosition()) {
            case 0:
                frameLayout.setBackgroundResource(R.mipmap.bg_test_6);
                break;
            case 1:
                frameLayout.setBackgroundResource(R.mipmap.bg_test_7);
                break;
            case 2:
                frameLayout.setBackgroundResource(R.mipmap.bg_test_8);
                break;
        }
    }
}
